// pages/storeDetails/storeDetails.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shop:{

      iscode: 0,
      iscollect: "收藏",
      img: "../../img/a_13_19.png",
      shoptitle: "西安车工坊行销部",
      desc: "连锁式汽车服务网点。",
      hassale: "20",
      hascollect: "5",
      movies: [
        { url: '../../img/banner_1.jpg' },
        { url: '../../img/banner_2.jpg' },
        { url: '../../img/banner_3.jpg' }
      ],
      business_time:'',
      phone :110,
      address : 'ssss',
      evaluate: [
        {
          src: "../../img/a_32_03.png",
          name: "小白",
          date: "2018-07-10",
          mes: "SB东西，来咬我 啊，小贱人！"
        }
      ]
    },
    configure: [
      { type: "营业时间", value: "周一至周日 00：00：00" },
      { type: "门店电话", value: "12121212121" },
      { type: "门店地址", value: "陕西省西安市未央区海洋大厦703" },
    ],
  },
  //收藏功能
  collect: function () {
    let that = this
    var bid = wx.getStorageSync('bid');
    if (bid) { bid = bid } else { bid = 0 }
    var iscode = that.data.iscode;
    wx.request({
      url: app.url + '/Business/add_collect',
      data: {
        uid: wx.getStorageSync('uid'),
        bid : bid
      },
      method  : 'post',
      success : function (res) {
        var code = res.data.res.code;
        if (code == 1) {
          wx.showToast({ title: '收藏成功', })
          that.setData({
            iscode : 1
          })
        } else if (code == 2) {
          wx.showToast({ title: '取消收藏', })
          that.setData({
            iscode: 0
          })
        } else {
          wx.showToast({ title: '操作失败', })
        }
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var uid = wx.getStorageSync('uid');
    var bid = e.options.bid;
    wx.request({
      url: app.url + '/Business/shop_detail',
      method: 'post',
      data: { bid: bid, uid: uid },
      success: function (res) {
        that.setData({
          shop: res.data.data
        })
      },
      error: function () { }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
   
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})